package com.home.timesheet.action;

import java.util.List;

import com.home.common.BaseAction;
import com.home.entity.User;
import com.home.timesheet.entity.TimesheetVO;
import com.home.timesheet.entity.TimesheetVOImpl;
import com.home.timesheet.service.TimesheetService;

@SuppressWarnings("serial")
public class TimesheetAction extends BaseAction {

    /**
     * BI 对象
     */
    private TimesheetService timesheetService;

    public void setTimesheetService(TimesheetService timesheetService) {
        this.timesheetService = timesheetService;
    }
    private List<TimesheetVOImpl> ts;
    



    public List<TimesheetVOImpl> getTs() {
        return ts;
    }

    public void setTs(List<TimesheetVOImpl> ts) {
        this.ts = ts;
    }

    /**
     * 页面跳转
     * 
     * @return
     */
    public String fill() {
        return "fillTimesheet";
    }
    
    /**
     * 保存数据
     * @return
     */
    public String save() {
        if(!ts.isEmpty()){
            timesheetService.saveList(ts);
        }
        return "fillTimesheet";
    }
    
    /**
     * 查询
     * @return
     */
    public String list() {
        List<TimesheetVOImpl> tslist = timesheetService.findAllByUserId(getUser().getUserId());
        System.out.println(tslist+":"+tslist.isEmpty());
        if(tslist.get(0) instanceof TimesheetVOImpl) {
            System.out.println(11);
        }else if(tslist.get(0) instanceof TimesheetVO){
            System.out.println(222);
        }else if(tslist.get(0) instanceof Object){
            System.out.println(222333);
        }
        super.getRequest().setAttribute("tslist", tslist);
        super.getRequest().setAttribute("xx", "xx");
        return "listTimesheet";
    }
}
